package com.lx.bigdata.manager;

import com.xl.bigdata.ai.sa.SentimentAnalysis;
import com.xl.bigdata.ai.sa.SentimentAnalysisOne;
import com.xl.bigdata.ai.tc.QXTextClassification;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName AIManager
 * @Description TODO
 * @Author xl.gao
 * @Date 2022/2/19 14:26
 * @Version
 */
@Configuration
public class AIManager  implements DisposableBean {

    /**
     * AI模型V·1
     */
    @Value("${ai.sentimentanalysis}")
    private String modelPath;

    private SentimentAnalysis sentimentAnalysis;

    /**
     * AI模型V·2
     */
    @Value("${ai.sentimentanalysisone}")
    private String modelPathOne;

    private SentimentAnalysisOne sentimentAnalysisOne;

    /**
     * AI模型V·2
     */
    @Value("${ai.qxtextclassification}")
    private String modelPathQX;

    private QXTextClassification qxTextClassification;

    @Bean(name = "sentimentAnalysis")
    @Qualifier(value = "sentimentAnalysis")
    public SentimentAnalysis getSentimentAnalysis(){
        SentimentAnalysis.initModel(modelPath);

        sentimentAnalysis = SentimentAnalysis.getInstance();
        return sentimentAnalysis;
    }

    @Bean(name = "sentimentAnalysisOne")
    @Qualifier(value = "sentimentAnalysisOne")
    public SentimentAnalysisOne getSentimentAnalysisOne(){
        SentimentAnalysisOne.initModel(modelPathOne);

        sentimentAnalysisOne = SentimentAnalysisOne.getInstance();
        return sentimentAnalysisOne;
    }

    @Bean(name = "qxTextClassification")
    @Qualifier(value = "qxTextClassification")
    public QXTextClassification getQXTextClassification(){
        QXTextClassification.initModel(modelPathQX);

        qxTextClassification = QXTextClassification.getInstance();
        return qxTextClassification;
    }


    @Override
    public void destroy() throws Exception {

    }
}
